Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

131
Visualizações
How can I use a variable in inheritance? (profile."item".name)?

First of all, if what I am describing in the title isn't called inheritance tell me a better word choice, I will update it. I just wasn't sure what to call it and wanted to get a solution as soon as possible.

Main file:

const items = require("../models/items")

for(var i = 0; i < 5; i++){
        if(i <= 4){
            let currentItem = profileData.items[]
            invEmbed.addFields(
                {name: `${items.currentItem.emoji}` + " " + `${items.currentItem.name} ` + " ― " + `${items.currentItem.amount}`, value: `${items.currentItem.description}`},
            ); 
        }
   }

"../models/items" Items file:

module.exports = {
    idcard: { 
        name: "ID Card",
        emoji: ":credit_card:",
        type: "tool",
        description: "Proves your identity."
    },
}

My problem is that on line 6 where I try to "items.currentItem.emoji" because I am trying to use a variable to move further in the inheritance, I am fairly new to javascript and I wanted to ask: Are you able to use variables when going through inheritance? If yes, how?

note: I am pretty sure its not called inheritance, maybe it is though, I am just using it because I don't know the proper word.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Use bracket notation. items[currentItem].emoji or items[currentItem]["emoji"].

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda